using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerJumpState : PlayerState
{
    public PlayerJumpState(Player player, StateMachine<PlayerState> stateMachine, string animBoolName) : base(player, stateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        player.SetVelocity(rb.velocity.x, player.jumpForce);
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();

        if (!Mathf.Approximately(xInput,0f))
        {
            player.SetVelocity(1.5f*xInput * player.moveInAirSpeed, rb.velocity.y);
        }

        if (rb.velocity.y <0 )
        {
            stateMachine.ChangeState(player.airState);
        }

        if (KeyInputManager.GetAttackKeyDown())
        {
            stateMachine.ChangeState(player.airAttackState);
        }
       
    }

    protected override bool CheckDashInput()
    {
        if (base.CheckDashInput() && player.dashCounterInAir < player.dashNumInAir)
        {
            player.dashCounterInAir++;
            return true;

        }
        return false;
    }
}
